Forward Rust logs through FFI to SDK logger#133
Open
alan-george-lk wants to merge 19 commits into
Open
Conversation
…test for Rust log forwarding
…/forward_rust_logs
alan-george-lk
commented
May 19, 2026
| return ffi_client.initialize(true); | ||
| } | ||
|
|
||
| bool isInitialized() { return FfiClient::instance().isInitialized(); } |
Collaborator
Author
There was a problem hiding this comment.
This accidentally made it in from an older PR (no header signature equivalent)
alan-george-lk
commented
May 19, 2026
| // Initializes logger if singleton instance is not already initialized | ||
| setLogLevel(level); | ||
| auto& ffi_client = FfiClient::instance(); | ||
| return ffi_client.initialize(log_sink == LogSink::kCallback); |
Collaborator
Author
There was a problem hiding this comment.
The log_sink variable was not working as I suspect it was intended previously. The argument to FfiClient::initialize here was to enable FFI logging (forwards all Rust log macros over the FFI callback as events), but LogSink::kCallback as a sink type is basically irrelevant to that feature. And passing that value here didn't actually register any callbacks. We should figure out what to do here, options are:
- Breaking change: simply remove the second arg to
livekit::initialize() - Just leave this
.initialize(true)as-is - Add a third enum value to
LogSinkcalledkOff, and then this arg becomes.initialize(log_sink != kOff), so users have the ability to turn off the FFI logs. But then that brings up the question, we probably should have a cleaner log control. Just turning off FFI logs while others remain doesn't really make sense
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does the following:
livekit::initialize(level, log_sink)is deprecated as of this PR but is still backwards compatible.log_sinkdid not accurately change logging behavior, andlivekit::setLogCallbackis actually the only way. The FFI log API change is independent of callback behavior, but this PR also ensures logs from SDK or FFI layer work the same sink-wise. Overloaded this withinitialize(level)and marked the other as deprecatedMinor unrelated changes that happened along the way:
panicevent the same way Python doesAGENTS.mdlanguage around format/tidyTesting
Added unit test to verify behavior across Error, Warn, Info and Debug levels (Trace not logged in Rust side).